﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//using Copy5x;

namespace Copy5xConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            //args = new string[] { "-copy", "src=c:\\temp\\src", "dest=c:\\temp\\dest" };
            //args = new string[] { "-cleardb" };

            #region Parse arguments

            foreach (Command cmd in Command.ParseCommand(args))
            {
                switch (cmd.CommandId)
                {
                    case "c":
                    case "copy":
                        _copy(cmd);
                        break;
                    case "?":
                    default:
                        callMan = true;
                        break;
                }
            }

            #endregion

            if (callMan)
                Man();
        }

        static void _copy(Command cmd)
        {
            string src = string.Empty;
            string dest = string.Empty;
            
            foreach (Param param in cmd.Args)
            {
                switch (param.Name.ToLower())
                {
                    case "src":
                        src = param.Value;
                        break;
                    case "dest":
                        dest = param.Value;
                        break;
                }
            }

            if (src == string.Empty || dest == string.Empty)
            {
                Copy5x.Logger.Log("Path is empty", Copy5x.LogType.Error, false);
            }
            else
            {
                Copy5x.Copy cpy = new Copy5x.Copy(src, dest);
                cpy = null;
            }
        }

        static bool callMan = false;

        /// <summary>
        /// Displays the manual
        /// </summary>
        static void Man()
        {
            string usage = Environment.NewLine + "\tUsage" + Environment.NewLine;
            usage += "\tTo Copy files from c:\\temp\\src to c:\\temp\\dest" + Environment.NewLine;
            usage += "\t\t Copy5x.exe -copy src=c:\\temp\\src dest=c:\\temp\\dest" + Environment.NewLine;

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine(usage);
            Console.ForegroundColor = ConsoleColor.White;
        }
    }
}
